package com.ss.project.xia17user.service;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.ss.project.xia17user.dao.entity.User;
import com.ss.project.xia17user.dao.mapper.UserMapper;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * @author xia17
 * @since 2020/9/16 15:30
 */
@Service
@Transactional(rollbackFor = Exception.class)
@RequiredArgsConstructor
public class UserService {

    private final UserMapper userMapper;

    /**
     * 根据用户名查找用户
     * @param username 用户名
     * @return /
     */
    public User findByUsername(String username){
        return userMapper.selectOne(Wrappers.<User>lambdaQuery()
                .eq(User::getUsername, username));
    }

}
